<?php
include_once("IController.php"); 
abstract class Controller implements IController
{
  protected $ac;
  protected $service;
  //validate all
  public function before_all_action()
  {
  }
  public function getAction()
  {
    return $this->empty($_GET['ac'])?"defaultAction":$_GET['ac'];
  }
  /**
   *根据请求头信息返回不同信息
   */  
  public function defaultAction()
  {
     foreach (getallheaders() as $name => $value)
      {
        if(strtoupper($name)==="ACCEPT")
        {
          //json
          if(strripos($value,"json")!=false)
            echo json_encode(array("status"=>"err","msg"=>"no such action"));
          else
          //html
          echo "<h2>Error</h2><p>sorry,we could not found the action,<a href='#' onclick='javascrpt:window.history.go(-1)'>click here to go back</a></p>";
          break;
      }
    }
  }
  public function after_all_action()
  {
  }
}
 ?>